common = {
  // 设置rem宽度 20px
  initRemSize: function() {
    document.documentElement.style.fontSize = 20 * document.documentElement.clientWidth / 375 + 'px'
  },
  //获取短信验证码
  getSms: function(elem, action) {
    var $this = $(elem);
    var mobile = $('#mobile').text(),
      reg = {
        mobile: /^1[3|4|5|6|7|8|9][0-9]{9}$/
      };
    if (reg.mobile.test(mobile)) {
      $this.attr('disabled', true);
      weui.topTips('获取验证码成功');
      $this.html("120s后重新获取");
      var nTime = 120;
      var timer = setInterval(function() {
        nTime--;
        if (nTime > 0) {
          $this.html(nTime + "s后重新获取");
        } else {
          clearInterval(timer);
          $this.removeAttr("disabled").html("获取验证码");
        }
      }, 1000);
      $this.removeClass('btn-disabled');
      $this.on('click', function(event) {
        getSms(elem, action);
      });
      return false;
    } else if (!reg.mobile.test(mobile)) {
      weui.topTips('手机格式错误')
      if (mobile === '') {
        weui.topTips('请输入手机号码')
      }
    }
  },
  //自动跳转页面
  autoLocationTo: function(elem, url) {
    var $this = $(elem);
    var ntime = 5;
    var timer = setInterval(function() {
      ntime--;
      if (ntime > 0) {
        $this.html(ntime + "秒");
      } else {
        window.location.href = url;
      }
    }, 1000);
  },

  //获取url参数
  getQueryString: function(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
  }
}